﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_ChangeInfoMember : System.Web.UI.UserControl
{
    string pass;
    int quyen;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["User"] !=null)
        {
            mtvwChangeInfo.ActiveViewIndex = 0;
            ThanhVienBLL itvien = new ThanhVienBLL();
            ThanhVien tvien = itvien.SelectByEmail(HttpContext.Current.Session["User"].ToString().Trim());
            lbEmail.Text = HttpContext.Current.Session["User"].ToString();
            lbDiaChi.Text = tvien.DiaChi;
            lbNgaySinh.Text = tvien.NgSinh.ToShortDateString();
            lbSoDT.Text = tvien.Sodt;
            lbHoTen.Text = tvien.HoTen;
            //quyen = tvien.MaQuyen.MaQuyen;
        }
        else
        {
            Response.Redirect("Login.aspx");
        }

    }

    protected void btUpdate_Click(object sender, EventArgs e)
    {
        ThanhVienBLL bllTV = new ThanhVienBLL();
        ThanhVien tvien = new ThanhVien();
        tvien.Email = lbEmail.Text.Trim() ;
        Response.Write(tvien.Email);
        if (txtHoTen.Text.Trim() != "")
        {
            tvien.HoTen = txtHoTen.Text.Trim();
        }
        else
        {
            tvien.HoTen = lbHoTen.Text.Trim();
        }
        if (txtDiaChi.Text.Trim() != "")
        {
            tvien.DiaChi = txtDiaChi.Text.Trim();
        }
        else
        {
            tvien.DiaChi = lbDiaChi.Text.Trim();
        }
        if (txtNgaySinh.Text.Trim() != "")
        {
            tvien.NgSinh = DateTime.Parse(txtNgaySinh.Text.Trim());
        }
        else
        {
            tvien.NgSinh = DateTime.Parse(lbNgaySinh.Text.Trim());
        }
        Response.Write(tvien.HoTen);
        if (txtSDT.Text.Trim() != "")
        {
            tvien.Sodt = txtSDT.Text.Trim();
        }
        else
        {
            tvien.Sodt = lbSoDT.Text.Trim();
        }

        QuyenBLL quyenbll = new QuyenBLL();
        tvien.MaQuyen = quyenbll.GetQuyenById(3);
      //  Response.Write(quyen.ToString()+ pass);
        string result = bllTV.ChangeInfoMember(tvien);
        Response.Write("<script>alert('"+tvien.Email + result+"')</script>");


    }
}